Skip to content

Add: comprehensive unit test suite for C++ runtime and Python utilities#427

Open
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:add-unit-tests-cpp-and-python
Open

Add: comprehensive unit test suite for C++ runtime and Python utilities#427
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:add-unit-tests-cpp-and-python

Conversation

@chenshengxin2026
Copy link
Copy Markdown
Contributor

@chenshengxin2026 chenshengxin2026 commented Apr 1, 2026

Summary

  • Reorganize tests/ut/cpp/ into domain-based subdirectories: hierarchical/, pto2_a2a3/, pto2_a5/, types/, hardware/, platform/
  • Expand C++ GoogleTest coverage from 10 to 30+ test binaries covering PTO2 runtime internals: ring buffer (incl. edge cases), scheduler (state + edge), tensormap (incl. edge), shared memory, ready queue, runtime graph/lifecycle/status, handshake, coupling, orchestrator fatal/submit, boundary edge, dispatch payload, core/submit types, worker manager, and platform stubs
  • Add shared test_helpers.h header and stubs/ directory for reusable test infrastructure
  • Add 5 new Python UT modules: test_elf_parser.py, test_env_manager.py, test_kernel_compiler.py, test_runtime_compiler.py, test_toolchain_setup.py
  • Update conftest.py with improved path setup for isolated UT execution
  • Update docs/testing.md, docs/ci.md for new UT layout; add docs/ut-test-suite.md describing the full test inventory
  • Minor fixes in runtime_compiler.py for testability

C++ test directory layout

tests/ut/cpp/
├── hardware/          # HCCL comm tests (requires_hardware label)
��── hierarchical/      # Orchestrator, ring, scheduler, scope, tensormap, worker_manager
├── platform/          # Platform host_log, memory_allocator stubs
├── pto2_a2a3/         # PTO2 A2A3 runtime: ring_buffer, scheduler, tensormap,
│                      #   shared_memory, ready_queue, coupling, handshake, types, edge cases
├── pto2_a5/           # PTO2 A5 runtime fatal tests
├── stubs/             # Shared test stubs (test_stubs.cpp)
├── types/             # Child memory, PTO types, tensor
├── test_helpers.h     # Shared test helpers
└── CMakeLists.txt     # All test targets with no_hardware / requires_hardware labels

Known defect-exposing tests

Several tests intentionally verify known src defects (documented in the test suite doc). These are preserved as regression anchors per project policy — they will pass once the underlying issues are fixed:

  • TensorMap check_overlap() dimension mismatch (HIGH)
  • TensorMap cleanup slot collision on large windows (HIGH)
  • TensorMap lookup saturation with 16+ producers (MEDIUM)
  • SharedMemory missing task_window_size >= 1 validation (LOW)

Test plan

  • C++ UT build succeeds
  • C++ UT no_hardware tests run
  • Python UT passes (44 tests)
  • CI ut-cpp job passes on ubuntu-latest
  • Simulation tests unaffected (no runtime/platform code changes)

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive suite of unit tests for the runtime system, covering core types, scheduling logic, memory management, and tensor operations. It includes a CMake configuration for building these tests with GoogleTest, along with platform stubs for x86 compatibility. Feedback was provided to improve the robustness of a CMake helper function by ensuring it verifies the existence of all source files, including extra sources, to prevent potential build failures.

Comment thread tests/ut/cpp/CMakeLists.txt Outdated
@chenshengxin2026 chenshengxin2026 changed the title Add: unit tests for C++ runtime modules and Python utilities [WIP] Add: unit tests for C++ runtime modules and Python utilities Apr 9, 2026
@chenshengxin2026 chenshengxin2026 force-pushed the add-unit-tests-cpp-and-python branch from 9aa9681 to 5b0a79c Compare April 21, 2026 11:23
@chenshengxin2026 chenshengxin2026 changed the title [WIP] Add: unit tests for C++ runtime modules and Python utilities Add: comprehensive unit test suite for C++ runtime and Python utilities Apr 21, 2026
@chenshengxin2026 chenshengxin2026 force-pushed the add-unit-tests-cpp-and-python branch 7 times, most recently from 7efd01c to eaf02a5 Compare April 22, 2026 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant